package com.library.collection.dao;

import com.framework.BaseDao;
import com.library.entity.Collection;
import com.library.entity.Staff;
import org.springframework.stereotype.Repository;

@Repository
public class CollectionDaoImpl extends BaseDao<Collection,String> {

	public Collection findByStaff(Staff staff){
		try{
			return super.findOne("from Collection c where c.staff=?", new Object[]{staff});
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}

	public Collection getCollectionById(Integer collectionId){
		try{
			return super.get(collectionId);
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}


	public void saveCollection(Collection collection){
		try {
			this.save(collection);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void updateCollection(Collection collection){
		try {
			this.update(collection);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public void deleteCollection(Collection collection){
		try {
			this.delete(collection);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
